import {defineStore} from 'pinia'
import {computed, onBeforeMount, ref} from "vue";

const values = ["镐", "斧", "锄", "锹", "剑", "头盔", "胸甲", "护腿", "鞋子", "三叉戟", "弓", "弩", "剪刀", "盾", "鱼竿", "打火石", "萝卜钓竿", "鞘翅"];
import {tableDataStore} from "@/stores/tableData.js";

export const selectItemStore = defineStore('selectItem', () => {
    const tableDataStr = tableDataStore()
    const list = ref([])

    function click(index) {
        list.value[index].select = !list.value[index].select;
        // 延迟1秒执行
        tableDataStr.getData();
    }

    onBeforeMount(() => {
        // 在组件挂载之前初始化 list 数组并赋值
        values.forEach(value => {
            list.value.push({
                value: value,
                select: false
            });
        });
    });

    return {list, click}
})
